<? 
	if(isset($_POST['btngo']))
	{
		require("required/dbconnect.php");
		$main_cat=$_POST['main_cat'];
		$pageno=$_POST['pageno'];
		header("Location:uploadfiles.php?page=$pageno");
	}
	
	$title="User List"; 
	$pageid="4";
	$accessid=",a10,";

	if(isset($_POST['btnsubmit']))
	{
		require("required/dbconnect.php");
		
		$content_chn=mysql_escape_string($_POST['content_chn']);
		$content_eng=mysql_escape_string($_POST['content_eng']);
		$url_chn=$_POST['url_chn'];
		$url_eng=$_POST['url_eng'];
		$create_date=$_POST['create_date'];
		$status=$_POST['status'];
		$insert=mysql_query("insert into os_news(content_chn,content_eng,url_chn,url_eng,create_date,status)value('$content_chn','$content_eng','$url_chn','$url_eng','$create_date','$status')")or die(mysql_error());
		header("Location:news.php");
	}

	require("required/dbconnect.php"); 
	require("required/function.php");
	require("required/header.php");
	

	
	if(empty($_GET['page']))
	{
		$page="1";
	}
	else
	{
		$page=$_GET['page'];
	}
	
	$totalperpage=20;

	$from=($page-1)*$totalperpage;	
	
	$get_files=mysql_query("select * from os_uploadfiles order by id desc limit $from,$totalperpage")or die(mysql_error());
	$get_total=mysql_query("select * from os_uploadfiles")or die(mysql_error());
	
	
	$count=mysql_num_rows($get_total);

	$totalpage=$count/$totalperpage;
	
	if($count%$totalperpage>0)
	{
		if(round($totalpage)>$totalpage)
		{
			$totalpage=round($totalpage);
		}
		else
		{
			$totalpage=round($totalpage+1);
		}
	}
	else
	{
		$totalpage=round($totalpage);
	}
	
	
	$nextpage=$page+1;
	$prepage=$page-1;
	
	
	
	
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
<tr>
	<td valign="top">
	
			<font class="title">Upload Files</font>
			<table width="100%">
				<td width="47%" height="45">
				<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
				<input type="button" class="button" value="<<" onClick="window.open('uploadfiles.php?page=1','_self')">
				<input type="button" class="button" value="<" onClick="window.open('uploadfiles.php?page=<?= $prepage ?>','_self')">
				<input type="hidden" value="<?= $main_cat ?>" name="main_cat">
				Page <input type="text" name="pageno" value="<?= $page ?>" size="2" maxlength="3" class="text"> of <?= $totalpage ?>
				<input type="submit" value="Go" class="button" name="btngo">
				<? if($page==$totalpage){ ?>	
				<input type="button" class="button" value=">" >
				<? }else{ ?>
				<input type="button" class="button" value=">" onClick="window.open('uploadfiles.php?page=<?= $nextpage ?>','_self')">
				<? } ?>
				<input type="button" class="button" value=">>" onClick="window.open('uploadfiles.php?page=<?= $totalpage ?>','_self')">
				
				</form>
				
				</td>
			</table>
			Right click on the desired image and select copy to paste it into any Java Editor.
			<table width="100%" class="solidborder">
				<tr class="table_header">
					<td width="2%">No</td><td width="24%">File name</td><td width="37%">Thumbnail</td><td width="33%">Larger Size</td><td width="4%">Action</td>
				</tr>
				<? if(mysql_num_rows($get_files)==0){ ?>
				<tr valign="top">
					<td align="center" colspan="7">
					- No record found - 
					</td>
				
				<? 
					}
					else
					{
						$no=1;
						while($a=mysql_fetch_array($get_files,MYSQL_ASSOC))
						{
							$enid=en_id($a['id']);
							if($no%2==0)
							{
								$class1="table_item_even";
								$class2="table_item_odd";
							}
							else
							{
								$class1="table_item_odd";
								$class2="table_item_even";
							}				
							
				?>
			   <tr height="20" valign="top" class="<?= $class1 ?>" onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='<?= $class1 ?>'">
						<td align="center"><?= $no ?></td>
						<td><?= $a['filename'] ?></td>
						<td align="center">
						<img src="../uploadfiles/thumbnails/<?= $a['filename'] ?>.gif" width="50">
						<br>
						

						</td>
						<td align="center">
							<img src="../uploadfiles/<?= $a['filename'] ?>.gif" width="100"><br>
						Image real size = <?= $a['width'] ?> x <?= $a['height'] ?>
						</td>
						<td align="center"><a href="uploadfiles_delete.php?id=<?= $enid ?>"> <img src="images/icons/delete.gif" border="0"></a></td>								
			  </tr>
				<? 
					$no++; 
						}
					}
				?>
				
			</table>
			<script type="text/javascript" src="required/js/calendarDateInput.js"></script>		
			
			<script language="javascript">
				function frmValidate(frm)
				{
					if(document.frm.filename.value=="")
					{
						alert("Please enter file name");
						document.frm.filename.focus();
						return false;
					}
					return true;
				}
			</script>
		<table>
			<tr>
				<td colspan="3"><strong>Upload New Files</strong></td>
			</tr>
			<form method="post" name="frm" enctype="multipart/form-data" action="uploadfiles2.php" onSubmit="return frmValidate(this)">
			<tr> 
					<td valign=top align="left"> 
					<font size=+1>Notice:</font>
					<ul>
					<li>The file size must less than 2MB</li>
					<li>must in jpg or gif format.</li>
					</ul>
					</td>
				</tr>
			<tr>
				<td>
				<input type="hidden" name="MAX_FILE_SIZE" value="2000000"> 
				  <input type="file" name="file" class=button><br>
				  <br>
				  
				  File name : <input type="text" size="10" maxlength="50" value="" name="filename" class="text"> 
				  <input type="submit" value="upload" name=submit class=button> 
				</td>
			</tr>
			</form>
			
		</table>

		</td>
	</tr>
	
	
</table>
<? require("required/footer.php"); ?>

